{% assign blockId = block_id | default: section.block_id %}
{% assign data = section.settings %}

<div class="block_testimonials" style="--bg: {{data.bg_color}};--padding: {{data.padding.top}}px {{data.padding.right}}px {{data.padding.bottom}}px {{data.padding.left}}px;">
  <div class="container_wrapper">
    <div class="content public_radius flex md:flex-row-reverse flex-col gap-10" style="--text-color: {{data.text_color}};">
      <div class="img_box flex-1 overflow-hidden">
        <div class="swiper overflow-hidden relative" id="swiper-img-{{blockId}}">
          <ul class="swiper-wrapper">
            {% for block in section.blocks %}
              <li class="swiper-slide">
                <div class="public_radius overflow-hidden">
                  {% include 'lazy_img',src: block.image.src,alt: block.image.alt,class: 'w-full object-cover' %}
                </div>
                {% if block.img_detail != '' %}
                  <div class="mt-4">
                    {{block.img_detail}}
                  </div>
                {% endif %}
              </li>
            {% endfor %}
          </ul>

          <div class="btn absolute top-3 right-3 flex gap-3 z-10">
            <div class="swiper-button-prev" id="img_swiper-button-prev-{{blockId}}">
              <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon feather feather-chevron-left"><title>Left</title><polyline points="15 18 9 12 15 6"></polyline></svg>
            </div>
            <div class="swiper-button-next" id="img_swiper-button-next-{{blockId}}">
              <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon feather feather-chevron-right"><title>Right</title><polyline points="9 18 15 12 9 6"></polyline></svg>
            </div>
          </div>
        </div>
      </div>
      <div class="text_box md:w-[30%] flex-shrink-0">
        <div class="swiper md:mt-[30px] overflow-hidden" id="text-swiper-{{blockId}}">
          <ul class="swiper-wrapper">
            {% for block in section.blocks %}
              <li class="swiper-slide">
                <div class="star">
                  {% for i in (1..block.star) %}
                    <svg width="16" height="16" aria-hidden="true" focusable="false" width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"></path></svg>
                  {% endfor %}
                </div>
                {% if block.title != '' %}
                  <div class="public_title mt-4">{{block.title}}</div>
                {% endif %}
                {% if block.name != '' %}
                  <div class="text_name mt-4">{{block.name}}</div>
                {% endif %}
                
              </li>
            {% endfor %}
          </ul>
        </div>
      </div>
    </div>
  </div>
</div>

<script>
  $(function(){
    let slideIndex = 1
    let size = '{{section.blocks.size}}'
    let textOptions = {
      allowTouchMove: false,
	  speed: 700
    }
    if($(window).width() >= 768) {
      textOptions.effect = 'fade'
    }else{
      textOptions.loop = true
	  textOptions.autoHeight = true
    }
    let textSwiper = new Swiper('#text-swiper-{{blockId}}', {
      ...textOptions
    })

    let imgSwiper = new Swiper('#swiper-img-{{blockId}}', {
      slidesPerView: $(window).width() >= 768 ? 2.4 : 1,
      spaceBetween : 20,
      loop: true,
      normalizeSlideIndex: false,
      navigation: {
        nextEl: "#img_swiper-button-next-{{blockId}}",
        prevEl: "#img_swiper-button-prev-{{blockId}}",
      },
      on: {
        slideChange: function() {
          textSwiper.slideTo(this.realIndex)
        }
      }
    })
  })
</script>

{% schema %}
{
	"class": "block_testimonials",
	"is_global": false,
	"icon": "icon-lunbotu",
	"name": {
		"zh_CN": "团队介绍",
		"en_US": "Team Introduction"
	},
	"max_blocks": "10",
	"blocks": [
		{
			"name": {
				"zh_CN": "团队介绍",
				"en_US": "Team Introduction"
			},
			"type": "item",
			"settings": [
				{
					"type": "card_image",
					"label": {
						"zh_CN": "图片",
						"en_US": "Image"
					},
					"default": {
						"src": "",
						"alt": ""
					},
					"info": {
						"zh_CN": "建议宽度1000px以上，高度自适应",
						"en_US": "Recommended width more than 1000px, height adaptive"
					},
					"id": "image"
				},
				{
					"type": "card_text_editor",
					"label": {
						"zh_CN": "简短描述",
						"en_US": "Short description"
					},
					"id": "img_detail",
					"default": ""
				},
				{
					"type": "card_header",
					"label": {
						"zh_CN": "成员设置",
						"en_US": "Member settings"
					}
				},
				{
					"type": "card_slider",
					"label": {
						"zh_CN": "评分",
						"en_US": "Rating"
					},
					"id": "star",
					"max": 5,
					"min": 1,
					"unit": "",
					"default": 5
				},
				{
					"type": "card_text_editor",
					"label": {
						"zh_CN": "标题",
						"en_US": "Title"
					},
					"id": "title",
					"default": ""
				},
				{
					"type": "card_input",
					"label": {
						"zh_CN": "名称",
						"en_US": "Name"
					},
					"id": "name",
					"default": ""
				}
			]
		}
	],
	"settings": [
		{
			"type": "card_layout",
			"label": {
				"zh_CN": "内容留白",
				"en_US": "Content blank"
			},
			"id": "padding",
			"default": {
				"top": "30",
				"left": "30",
				"right": "30",
				"bottom": "30"
			}
		},
		{
			"type": "card_header",
			"label": {
				"zh_CN": "颜色设置",
				"en_US": "Color Settings"
			}
		},
		{
			"type": "card_color",
			"id": "text_color",
			"label": {
				"zh_CN": "文字颜色",
				"en_US": "Text color"
			},
			"default": "#141414"
		},
		{
			"type": "card_color",
			"id": "bg_color",
			"label": {
				"zh_CN": "背景颜色",
				"en_US": "Background color"
			},
			"default": "#ffffff"
		}
	],
	"default": {
		"settings": {
			"padding": {
				"top": "30",
				"left": "30",
				"right": "30",
				"bottom": "30"
			},
			"text_color": "#404040",
			"bg_color": "#ffffff"
		},
		"blocks": [
			{
				"image": {
					"src": "",
					"alt": ""
				},
				"img_detail": "",
				"star": 5,
				"title": "Add customer reviews and testimonials to showcase your store’s happy customers.",
				"name": "Author's name",
				"block_type": "item"
			},
			{
				"image": {
					"src": "",
					"alt": ""
				},
				"img_detail": "",
				"star": 5,
				"title": "Add customer reviews and testimonials to showcase your store’s happy customers.",
				"name": "Author's name",
				"block_type": "item"
			},
			{
				"image": {
					"src": "",
					"alt": ""
				},
				"img_detail": "",
				"star": 5,
				"title": "Add customer reviews and testimonials to showcase your store’s happy customers.",
				"name": "Author's name",
				"block_type": "item"
			},
			{
				"image": {
					"src": "",
					"alt": ""
				},
				"img_detail": "",
				"star": 5,
				"title": "Add customer reviews and testimonials to showcase your store’s happy customers.",
				"name": "Author's name",
				"block_type": "item"
			}
		]
	}
}
{% endschema %}
